package com.kgc.dubbo.controller;

import com.kgc.dubbo.service.LocalOrderService;
import com.kgc.dubbo.vo.RespResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 商品操作的控制器
 */
@Api(value = "商品操作的控制器")
@RestController
@RequestMapping("/api")
public class OrderController {
    @Autowired
    private LocalOrderService localOrderService;
    @ApiOperation(value = "根据用户编号查询订单列表信息",
            httpMethod = "POST",
            protocols = "http",
            notes = "根据用户编号查询订单信息",
            produces = "application/json;charset=UTF-8",
            consumes = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name ="id",value = "商品编号",required = true,paramType = "form"),
            @ApiImplicitParam(name ="token",value = "token",required = true,paramType = "form")
    })
    @PostMapping(value = "v/queryOrderList")
    public RespResult queryOrderList(String id,String token) throws Exception {
        RespResult respResult = localOrderService.orderListByUser(id,token);
        return respResult;
    }

    @ApiOperation(value = "根据订单编号查询订单信息",
            httpMethod = "POST",
            protocols = "http",
            notes = "根据用户编号查询订单信息",
            produces = "application/json;charset=UTF-8",
            consumes = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name ="orderId",value = "订单编号",required = true,paramType = "form")
    })
    @PostMapping(value = "v/prepay")
    public RespResult queryOrder(String orderId) throws Exception {
        RespResult respResult = localOrderService.getOrderById(orderId);
        return respResult;
    }

    @ApiOperation(value = "根据订单编号(orderNo)查询订单信息",
            httpMethod = "POST",
            protocols = "http",
            notes = "根据用户编号(orderNo)查询订单信息",
            produces = "application/json;charset=UTF-8",
            consumes = "application/json")
    @ApiImplicitParams({
            @ApiImplicitParam(name ="orderNo",value = "订单编号",required = true,paramType = "form")
    })
    @PostMapping(value = "v/orderInfo")
    public RespResult queryOrderByOrderNo(String orderNo) throws Exception {
        RespResult respResult = localOrderService.getOrderByOrderNo(orderNo);
        return respResult;
    }

}
